package edu.zju.gis.dbfg.model.statistic;

import lombok.Getter;
import lombok.Setter;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

@Getter
@Setter
public class SelectByAttributeArgs implements Serializable {

    private final static Logger logger = LoggerFactory.getLogger(SelectByAttributeArgs.class);

    @Option(name = "-output",usage = "输出文件路径", required = true)
    private String output;

    @Option(name = "-input",usage = "输入数据路径", required = true)
    private String input;

    @Option(name = "-type",usage = "输入数据类型", required = true)
    private String type;

    @Option(name = "-idIndex",usage = "输入数据id(wkt需)", required = true)
    private String idIndex;

    /**
     * 属性，对于wkt文件，则是数字，对于shapefile文件，则是字段名
     */
    @Option(name = "-filterIndex",usage = "过滤字段", required = true)
    private String filterIndex;

    @Option(name = "-filters",usage = "过滤值", required = true)
    private String filters;

    @Option(name = "-crs",usage = "坐标系")
    private String crs = "4326";

    public  static SelectByAttributeArgs initArgs(String args[]){
        SelectByAttributeArgs mArgs = new SelectByAttributeArgs();
        CmdLineParser parser = new CmdLineParser(mArgs);
        try {
            parser.parseArgument(args);
            return mArgs;
        } catch (CmdLineException e) {
            logger.error(e.getLocalizedMessage());
            return null;
        }
    }
}
